<?php

namespace Faye\controllers;

use Faye\core\BaseController;
use Faye\core\CoreEnums;
use Faye\models\TestModel;
use Faye\traits\Demo;

class IndexController extends BaseController
{
    use Demo;

    public function __construct()
    {
        parent::__construct();
    }

    public function index($req, $res)
    {
        var_dump($req->get);
        echo $this->p($this->demo());
        echo $this->p(CoreEnums::$article_flag);
        $testModel = new TestModel();
        echo $this->p($testModel->test());
        return msg(1, "index/index", $req->get);
    }

    public function random()
    {
        $factory = new \RandomLib\Factory;
        $generator = $factory->getGenerator(new \SecurityLib\Strength(\SecurityLib\Strength::MEDIUM));
        $randomString = $generator->generateString(32, 'abcdef');
        return msg(1, "", [
            'randomString' => $randomString,
        ]);
    }

    public function error()
    {
        new aaa();
    }
}